package sjtu.rfid.rri.services.tag;

import java.io.Serializable;
import java.util.Date;

import javax.xml.bind.annotation.XmlRootElement;

/**
 * This interface defines the basic tag event
 * 
 * @author jinghao
 */
@XmlRootElement
public class TagEvent implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 964316023139952355L;

	private TagModel tagModel;

	private String readerID;

	private long timeStamp;

	/**
	 * @return the tagModel
	 */
	public TagModel getTagModel() {
		return tagModel;
	}

	/**
	 * @param tagModel
	 *            the tagModel to set
	 */
	public void setTagModel(TagModel tagModel) {
		this.tagModel = tagModel;
	}

	/**
	 * @return the readerID
	 */
	public String getReaderID() {
		return readerID;
	}

	/**
	 * @param readerID
	 *            the readerID to set
	 */
	public void setReaderID(String readerID) {
		this.readerID = readerID;
	}

	/**
	 * @return the timeStamp
	 */
	public long getTimeStamp() {
		return timeStamp;
	}

	/**
	 * @param timeStamp
	 *            the timeStamp to set
	 */
	public void setTimeStamp(long timeStamp) {
		this.timeStamp = timeStamp;
	}

	@Override
	public boolean equals(Object obj) {
		if (obj == this)
			return true;
		if (!(obj instanceof TagEvent))
			return false;

		TagEvent tag = (TagEvent) obj;
		return (tagModel == null ? tag.tagModel == null : tagModel
				.equals(tag.tagModel))
				&& (readerID == null ? tag.readerID == null : readerID
						.equals(tag.readerID));
	}

	@Override
	public int hashCode() {
		int result = 17;
		if (null != tagModel) {
			result = 37 * result + tagModel.hashCode();
		}
		if (null != readerID) {
			result = 37 * result + readerID.hashCode();
		}
		return result;
	}

	@Override
	public String toString() {
		return "tagEvent[readerID=" + readerID + ",tagModel=" + tagModel
				+ ",timeStamp=" + new Date(timeStamp) + "]";
	}
}
